package features.advance.jdk.regexp;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

/**
 * @author LIN
 * @date 2021-12-14 18:36
 */
public class Exercise {

    public static void main(String[] args) throws Throwable {
        Solution solution = new Solution() {
        };
//        solution.copy("D:/Readme.txt");
        int[] arr = {2,3,1,8,4,3,5};
        solution.bubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }

    static class Solution {
        public void copy(String scrFilePath) throws Throwable{
            File srcFile = new File(scrFilePath);
            if(srcFile.exists()){
                try{
                    String format = new SimpleDateFormat("yyyyMMdd").format(new Date());
                    String path = "E:/"+format;
                    new File(path).mkdir();
                    String targetFilePath = path +"/"+srcFile.getName();
                    File file = new File(targetFilePath);
                    FileInputStream fileInputStream = new FileInputStream(srcFile);
                    FileOutputStream fileOutputStream = new FileOutputStream(file);
                    int read = -1;
                    while((read = fileInputStream.read())!=-1){
                        fileOutputStream.write(read);
                    }

                    fileInputStream.close();
                    fileOutputStream.flush();
                    fileOutputStream.close();
                }catch(Exception e){
                    e.printStackTrace();
                }

            }
        }

        /**
         * 冒泡排序
         * @param arr
         */
        public void bubbleSort(int[] arr){
            for (int i = 0; i < arr.length; i++) {
                for (int j = i; j < arr.length; j++) {
                    if(arr[j] < arr[i]){
                        int tmp = arr[i];
                        arr[i] = arr[j];
                        arr[j] = tmp;
                    }
                }
            }
        }

        

    }
}
